import get from '@dfeidao/atom-web/local/get';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';

export default async function a002(fd: IFeidaoAiBrowserComponent) {

	const productid = get(fd, 'productid');
	//  删除
	const role_no = get(fd, 'role_no');
	const _id = get(fd, '_id');
	const role_type_id = get(fd, 'role_type_id');
	const role_name = get(fd, 'role_name');
	const icon = get(fd, 'icon');
	const ff = get(fd, 'ff');
	// console.log(_id, role_name, role_type_id, icon, ff)
	show_loading();
	const res1 = await nodejs('roler/zj-000010/s001', {
		_id,
		role_name,
		role_type_id,
		icon,
		productid
	});
	const res = await nodejs('roler/zj-000010/s002', { role_no, productid });
	hide_loading();
	if (res1 === 'success' && res === 'success') {
		fire('zj-000001', 'ec-002', ff);
		fire('zj-000003', 'eu-001');
		fire('zj-000010', 'eu-001');
		success('保存成功');
	} else {
		error('保存失败');
	}
}
